//
// Created by abstergo on 24-6-19.
//

#ifndef TBS_CPP_ITERATORS_H
#define TBS_CPP_ITERATORS_H

#include <structs/Iterable.h>

namespace tbs::structs::iterators {
template<typename T>
class PointerIterator : public tbs::structs::Iterator<T> {
private:
  T *_ptr = nullptr;
  size_t _size = 0, _index = 0;

public:

  PointerIterator(T *ptr, CONST size_t &size, CONST size_t &index = 0);

  virtual const void *source() const override;

  virtual const size_t index() const override;

  virtual tbs::structs::Iterator<T> &next() override;

  virtual bool has_next() const override;

  virtual T &value() override;

};

#include "inls/structs/PointerIteratorInl.cuh"

/**
 * @brief 整型数字遍历器
 */
class RangeIterator : public tbs::structs::Iterator<int> {
private:
  int _b, _e, _step;
public:
  /**
   * @brief
   * @param b 起始数字
   * @param e 结束数字 不包括
   */
  RangeIterator(int b, int e, int step = 1);

  virtual Iterator<int> &next() override;

  virtual bool has_next() const override;

  virtual int &value() override;

  virtual const void *source() const override;

  virtual const size_t index() const override;

};

/**
 * @brief 整型枚举器
 */
class IntRange : tbs::structs::Iterable<RangeIterator> {
private:
  int _b, _e, _s;
public:
  IntRange(int b, int e, int s = 1);

  virtual RangeIterator begin() NO_EXCEPT override;

  virtual RangeIterator end() NO_EXCEPT override;
};


#include "inls/structs/RangeInl.cuh"

}

#endif //TBS_CPP_ITERATORS_H
